package com.ruoyi.delivery.controller;

import com.ruoyi.delivery.domain.DelDeliveryDetail;
import com.ruoyi.delivery.service.IDeliveryDetailService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/delivery/deliveryDetail")
public class DelDeliveryDetailController {

    @Autowired
    private IDeliveryDetailService deliveryDetailService;

    /**
     * 根据配送单号查询配送单明细信息
     *
     * @param deliveryBatchId   配送单号
     * @param productName  产品名称
     * @param productBatch 产品批次
     * @param orderNumber  订单号
     * @return 配送单明细信息列表
     */
    @RequestMapping("/detail/{deliveryBatchId}")
    public List<DelDeliveryDetail> getDeliveryDetailsByDeliveryId(@Param("productName") String productName, @Param("productBatch") String productBatch, @Param("orderNumber") String orderNumber, @PathVariable String deliveryBatchId) {
        return deliveryDetailService.getDeliveryDetailsByDeliveryId(deliveryBatchId , productName, productBatch, orderNumber);
    }

    /**
     * 根据运单号获取配送编号
     * @param trackingNo 运单号
     * @return 配送编号 delivery_id
     */
    @PostMapping("/getDeliveryIdByTrackingNo")
    public String getDeliveryIdTrackingNo(@RequestParam String trackingNo) {
        return deliveryDetailService.getDeliveryIdByTrackingNo(trackingNo);
    }
}